#!/usr/bin/python
import os
import sys
import time
import subprocess
from os import popen
'''
result = os.popen('')
print(result.readlines())
result.close()
'''

def runP(command, encoding):
    p = subprocess.Popen(command, stdout=subprocess.PIPE)
    time.sleep(2)
    p.terminate()
    out, err = p.communicate()
    res = out.decode(encoding)
    return res


if __name__ == '__main__':
    commands = ['pidstat', 'iostat -d -x','iotop','fdisk –l','df -h']
    for each in commands:
        r = runP(each, "gbk")
        print(r)